//
//  DMISBannerManager.h
//  DualMediationSDK
//
//  Created by YeJary on 2025/7/9.
//

#import <Foundation/Foundation.h>
#import "../../API/AdStrategy/IMAdStrategyManager.h"
#import "DMAdDelegate.h"
#import "DMBannerTypes.h"

#if __has_include(<IronSource/IronSource.h>)
#import <IronSource/IronSource.h>
#define IRONSOURCE_AVAILABLE 1
#else
#define IRONSOURCE_AVAILABLE 0
// 当IronSource不可用时的占位类
@interface LPMBannerAdView : NSObject
@end
#endif

// 定义常量 - 移除不需要的常量

NS_ASSUME_NONNULL_BEGIN

@interface DMBannerManager : NSObject

// 双广告位支持属性
@property (nonatomic, assign) BOOL isDualAdEnabled;
@property (nonatomic, strong) NSString *currentPrimaryAdUnitId;
@property (nonatomic, assign) BOOL isPrimaryAdLoaded;
@property (nonatomic, assign) BOOL isSecondaryAdLoaded;
@property (nonatomic, assign) double primaryAdECPM;
@property (nonatomic, assign) double secondaryAdECPM;

// 重试机制相关属性
@property (nonatomic, assign) NSInteger maxRetryCount;        // 最大重试次数
@property (nonatomic, assign) NSInteger retryCount;          // 当前重试次数
@property (nonatomic, assign) NSInteger totalLoadAttempts;   // 总加载尝试次数
@property (nonatomic, assign) NSInteger totalFailureCount;   // 总失败次数
@property (nonatomic, assign) NSTimeInterval lastRetryTime;  // 上次重试时间
@property (nonatomic, assign) BOOL isRetryPaused;            // 是否暂停重试
@property (nonatomic, strong) NSTimer *retryTimer;           // 重试定时器

@property (nonatomic, assign)BOOL isLoadBanner;
@property (nonatomic, strong)LPMBannerAdView  * _Nullable bannerView;
@property (nonatomic, assign, readonly) BOOL isUserClosed;
@property (nonatomic, weak, nullable) id<DMAdDelegate> delegate;

+ (instancetype)shareBannerManager;
- (void)setBannerDelegate;
- (void)loadBanner;
- (void)showBanner;
- (void)showBannerWithScene:(IMAdScene)scene;
- (void)closeBanner;
- (void)hideBanner;
- (void)resumeBanner;
- (void)checkPendingBannerDisplay;
- (void)setBannerDirectionWithTop:(BOOL)topDir;
- (void)destroyBanner;

#pragma mark - Banner广告重构接口

/**
 * 展示场景化Banner广告
 * @param scene 场景枚举
 */
- (void)showBannerForScene:(DMBannerScene)scene;

/**
 * 隐藏场景化Banner广告
 * @param scene 场景枚举
 */
- (void)hideBannerForScene:(DMBannerScene)scene;

/**
 * 检查场景化Banner广告是否可用
 * @param scene 场景枚举
 * @return 是否可用
 */
- (BOOL)isBannerReadyForScene:(DMBannerScene)scene;

/**
 * 展示Banner广告（新接口）
 * @param scene 场景枚举
 * @param position Banner位置
 * @param enableShortScreenDetection 是否启用短屏检测
 */
- (void)showBannerAd:(DMBannerScene)scene 
            position:(BannerPosition)position 
enableShortScreenDetection:(BOOL)enableShortScreenDetection;

/**
 * 预加载场景Banner广告
 * @param scene 场景枚举
 */
- (void)preloadBannerForScene:(DMBannerScene)scene;

/**
 * 销毁场景Banner广告
 * @param scene 场景枚举
 */
- (void)destroyBannerForScene:(DMBannerScene)scene;

@end

NS_ASSUME_NONNULL_END
